#pragma once
#include "util.hpp"
#include <functional>

class Task
{
public:
    using callback_t = function<void(int, string, uint16_t)>;
    Task(callback_t func, int sock = -1, string ip = "", uint16_t port = -1)
        :_sock(sock), _ip(ip), _port(port), _f(func)
    {
    }

    void operator()()
    {
        Log(NOTICE, "线程ID[%p]处理%s : %d的任务", pthread_self(), _ip.c_str(), _port);
        _f(_sock, _ip, _port);
        Log(NOTICE, "线程ID[%p]处理完%s : %d的任务", pthread_self(), _ip.c_str(), _port);
    }
private:
    int _sock; //对应用户 sock;
    string _ip; //对应用户 ip;
    uint16_t _port; //用户 端口
    callback_t _f;
};
